program Asmall;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils;

function find(r, t: Int64): Int64;
var
  A, B, C, D, X: Comp;
begin
  A := 2;
  B := 2 * r - 1;
  C := - t;
  D := Sqr(B) - 4 * A * C;
  X := (- B + Sqrt(D)) / 2 / A;
  Result := Trunc(X);
end;

var
  f, g: TextFile;
  r, t, answer: Int64;
  TT: Word;

procedure ReadData;
begin
  Readln(f, r, t);
end;

procedure ProcessData;
begin
  answer := find(r, t);
end;


procedure OutputVerdict(casenum: Word);
begin
  writeln(g, 'Case #', casenum, ': ', answer);
end;

var
  i: Word;
  s: String;

begin
  try
    s := ParamStr(1);
    if (s = '') then
       s := 'input.txt';
    AssignFile(f, s);
    Reset(f);
    AssignFile(g, 'output.txt');
    Rewrite(g);
    try
      Readln(f, TT);
      for i := 1 to TT do begin
        ReadData;
        ProcessData;
        OutputVerdict(i);
      end;
    finally
      CloseFile(f);
      CloseFile(g);
    end;
  except
    on E: Exception do begin
      Writeln(E.ClassName, ': ', E.Message);
      readln;
    end;
  end;
end.
